import { createSlice, configureStore, PayloadAction } from '@reduxjs/toolkit'

export type UserStateType = {
  username: string,
  nickname: string,
}
const initState = {
  username: '',
  nickname: '',
}
const userSlice = createSlice({
  name: 'user',
  initialState: initState,
  reducers: {
    loginReducer(state, aciton: PayloadAction<UserStateType>) { // 登录
      return aciton.payload
    },
    logoutReducer: () => initState,
  }
})

export const { loginReducer, logoutReducer } = userSlice.actions
export default userSlice